package cn.gjculture.shopping.api.service.impl;

import cn.gjculture.shopping.api.dao.BannerDao;
import cn.gjculture.shopping.api.dao.CommonUpdateMapper;
import cn.gjculture.shopping.api.entity.Banner;
import cn.gjculture.shopping.api.entity.Return;
import cn.gjculture.shopping.api.service.BannerService;
import cn.gjculture.shopping.api.util.UUIDUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BannerServiceImpl implements BannerService {

    @Autowired
    BannerDao bannerDao;

    @Autowired
    CommonUpdateMapper commonUpdateMapper;

    @Override
    public int insert(Banner banner) {
        banner.setId(UUIDUtil.getUUID());
        banner.setStatus(1);
        return bannerDao.insert(banner);
    }

    @Override
    public int update(Banner banner) {
        return commonUpdateMapper.updateBanner(banner);
    }

    @Override
    public List<Banner> query() {
        return bannerDao.query();
    }

    @Override
    public Banner queryById(String id) {
        return bannerDao.queryById(id);
    }

    @Override
    public int delete(String id, Return<Banner> ret) {
        return bannerDao.delete(id);
    }
}
